package com.common.utils.timeUtils
{
	import flash.globalization.DateTimeFormatter;
	

	/**
	 * 时间转换工具 
	 * @author Administrator
	 * 
	 */	
	public class TimerUtils
	{
		private static var _date:Date;
		public function TimerUtils()
		{
		}
		/**
		 * 把时间转换成小时：分钟：钞
		 * 				00：00：00
		 * @param $time
		 * @return 
		 * 
		 */
		public static function changeToh_m_s($time:int):String
		{
			if($time <=0)return "00:00:00";
			var str:String="";
			var h:int = Math.floor($time/3600);
			str += changeToStr(h)+":";
			var m:int = Math.floor(($time - h *3600)/60);
			str += changeToStr(m)+":";
			var s:int = $time - h*3600 - m*60;
			str += changeToStr(s);
			function changeToStr($time:int):String
			{
				if($time < 10)
					return "0"+ $time;
				return $time.toString();
			}
			return str;
		}
		/**
		 * 把时间转换成小时 2012-9-15
		 * @param $time
		 * @return 
		 * 
		 */
		public static function changeY_M_D($time:int):String
		{
			if(_date == null)_date= new Date();
			_date.setTime($time * 1000);
			return _date.getFullYear() + "-"+ (_date.getMonth() + 1) + "-"+ _date.getDate() ;
		}
		/**
		 * 大于24小时 显示天 小于24小时 00：00：00
		 * @param $time
		 * @return 
		 * 
		 */
		public static function chageDate($time:int):String
		{
			if($time /3600 < 24)
			{
				return changeToh_m_s($time);
			}
				
			return Math.ceil($time /(3600 * 24)) + "天";
		}
	}
}